package com.emm.yixun.basic.exception;

public enum YIXUNExceptionCode {
	// 系统异常 runtime exception
	UNKNOW_EXCEPTON("9999", "未知异常", "服务器忙"),
	// 参数验证错误DSAVerifyParameException
	ILLEGAL_PARAMETER("1000", "参数异常", "参数异常"),
	// 业务验证错误DSAVerifyBusinessException
	MONEY_PARSE_ERROR("3003", "金额转换money类错误", "金额格式错误"),
	// 请求超时 runtime exception
	TIMEOUT_EXCEPTON("9998", "请求超时", "请求超时"), ;

	private YIXUNExceptionCode(String code, String desin, String desout) {
		this.code = code;
		this.desin = desin;
		this.desout = desout;
	}

	private String code;
	private String desin;
	private String desout;

	public String getCode() {
		return code;
	}

	public String getDesin() {
		return desin;
	}

	public String getDesout() {
		return desout;
	}

	public static YIXUNExceptionCode getByCode(String code) {
		if (code != null && !"".equals(code.trim())) {
			for (YIXUNExceptionCode mnum : values()) {
				if (mnum.getCode().equals(code)) {
					return mnum;
				}
			}
		}
		return null;
	}

	public static String getInMsg(String code) {
		if (code != null && !"".equals(code.trim())) {
			for (YIXUNExceptionCode mnum : values()) {
				if (mnum.getCode().equals(code)) {
					return mnum.getDesin();
				}
			}
		}
		return null;
	}

	public static String getOutMsg(String code) {
		if (code != null && !"".equals(code.trim())) {
			for (YIXUNExceptionCode mnum : values()) {
				if (mnum.getCode().equals(code)) {
					return mnum.getDesout();
				}
			}
		}
		return null;
	}
}
